<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateTaskProcessFile extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('task_process_file', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '任务过程文件表']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('task_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '任务id'])
            ->addColumn('file_name', 'string', ['null' => false, 'default' => '', 'limit' => 255, 'comment' => '文件名'])
            ->addColumn('json', 'json', ['null' => true, 'comment' => 'json字段，存储自定义字段'])
            ->addColumn('version', 'string', ['default' => '', 'limit' => 128, 'comment' => '版本号'])
            ->addColumn('created', 'integer', ['null' => false, 'default' => 0, 'limit' => 11, 'signed' => false, 'comment' => '创建时间'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->save();
    }

    public function down()
    {
        $this->table('task_process_file')->drop()->save();
    }
}
